/*工资确认*/
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:frametrim/appviews/salaryView.dart';
import 'package:frametrim/listeners/OnViewClickListener.dart';
import 'package:frametrim/utility/screen.dart';
import 'package:frametrim/utility/sq_color.dart';
import 'package:frametrim/views/appbar_black.dart';

class SalarySurePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => SalarySureStata();

}

class SalarySureStata extends State<SalarySurePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: AnnotatedRegion(
        value: SystemUiOverlayStyle.dark,
        child: Stack(
          children: <Widget>[
            Image.asset('image/background.png',
                fit: BoxFit.cover, width: Screen.width, height: Screen.height),
            /*Column嵌套ListView，ListView不显示 就使用Expanded包裹ListView*/
            Column(
              children: <Widget>[
                AppbarCenterTitle(
                  title: '工资确认',
                  imgStr: 'image/imv_back.png',
                  titleColor: SQColor.black,
                ),
                /*ListView没有和AppBar一起使用时，头部会有一个padding，
                为了去掉padding使用MediaQuery.removePadding*/
                Expanded(
                    child: MediaQuery.removePadding(
                  context: context,
                  child: ListView.builder(itemBuilder: (context, index) {
                    return build_list();
                  },
                  itemCount: 2,),
                  removeTop: true,
                ))
              ],
            )
          ],
        ),
      ),
    );
  }

  /*多个月份的工资*/
  List<Widget> buildAllData() {
    List<Widget> children = [];
    for (var i = 0; i < 3; i++) {
      children.add(Column(
        children: buildListItems(),
      ));
    }
    return children;
  }

/*添加工资列表*/
  List<Widget> buildListItems() {
    List<Widget> children = [];

    /*children.add(Container(
      width: Screen.width - 20,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '2022年2月工资条',
            style: TextStyle(fontSize: 16, color: Colors.black),
          ),
        ],
      ),
    ));*/
    children.add(SizedBox(
      height: 10,
    ));
    for (var i = 0; i < 3; i++) {
      children.add(SalaryView('测试', '班组名称', '待发放', '查看详情',''));
    }
    return children;
  }

  Widget build_list(){
    return Column(
      children: <Widget>[
        Container(
          width: Screen.width - 20,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                '2022年2月工资条',
                style: TextStyle(fontSize: 16, color: Colors.black),
              ),
            ],
          ),
        ),
        Column(
          children: buildListItems(),
        )
      ],
    );
  }


  @override
  void onConfirm(String id) {

  }
}
